<!DOCTYPE html>
<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<script>
function jiancha() {
    var x = $("#fname").val();
    if (x == null || x == "") {
        alert("需要输入用户名。");
        return false;
    }
    var a = $("#mima").val();
    if (a == null || a == "")
      {
    alert("请输入密码");
    return false;
    }
    var m = $("#mima").val();
        b = $("#mima1").val();
    if (b == null || b !== m )
  {
    alert("两次密码输入不一致");
    return false;
    }
    var x= $("#email").val();
    var atpos=x.indexOf("@");
    
    var dotpos=x.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
    {
        alert("不是一个有效的 e-mail 地址");
        return false;
        }
    var search_site = document.getElementById("fname").value;  
    var keyname = localStorage.getItem(search_site);  
       if(keyname!==null)
       {
           alert("用户名已使用");
           return false;
    }
  }
function save(){  
    var site = new Object;
    site.keyname = document.getElementById("fname").value;
    site.sitename = document.getElementById("email").value;  
    site.siteurl = document.getElementById("mima").value;
    var d=new Date();
    site.nowtime=d.toLocaleDateString();
    var str = JSON.stringify(site); // 将对象转换为字符串
    localStorage.setItem(site.keyname,str);  
 
    alert("注册成功");
  }
function find(){  
        var search_site = document.getElementById("1name").value;  
        var str = localStorage.getItem(search_site); 
     if(str==null)
     {
       alert("用户名不存在");
       return false;
     }
     var site = JSON.parse(str);
     if(document.getElementById("mima").value!=site.siteurl)
     {
       alert("密码不存在");
       return false;
     }
     sessionStorage.username =search_site;
     window.location.href='http://zhuguangqi.gitee.io/buptsice_training_2017_2/chenggong.html';
 }
</script>
</head>
<title>风流登录</title>
<body style="background-color: #F0E68C">
<h1 style="font-size:3em;text-align:center;color: rgba(50,150,0,0.7);">风流登录</h1>
<hr>
<form style="text-align:center;" name="myForm" method="get">
用户名:<input type="text" id="1name" placeholder="在此输入您的用户名"><br>
 <br>
 <br>
密码:<input type="password" id="mima" placeholder="在此输入您的密码"><br>
 <br>
 <br>
 <input type="button" onclick="find();" value="登陆">
</body>
</html>